<!--#INCLUDE FILE="config.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../styles.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!-- DATE PICKER SCRIPT -->
<link type="text/css" href="../css/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript">
	// ***** Session Timeout Warning and Redirect mReschke 2010-09-29 ***** //
function InitSessionTimer() {
    /* mReschke 2010-09-29 */
    warn_sec = <%=session.timeout%> * 60 * 1000;   	//Warning time in milliseconds
    timeout_sec = <%=session.timeout%> * 60 * 1000 + 60000;          //Actual timeout in milliseconds
    show_warning = true;
    epoch = new Date().getTime();
    CheckSessionStatus();
}
InitSessionTimer();
function CheckSessionStatus() {
    /* mReschke 2010-09-29 */
 
    //Check for session warning
    epoch2 = new Date().getTime();
     if (epoch2 > epoch + timeout_sec) {
        alert("Your session has timed out.");
        window.location.href = 'default.asp?msg=invalid_out';
    } else {
        down = setTimeout("CheckSessionStatus();", 2000);
    }
}
</script>
<script>
	$(function() {
		$( "#fecha" ).datepicker();
		$( "#visitfecha" ).datepicker();
	});
	</script>
  <!-- END DATE PICKER SCRIPT -->

<script type="text/javascript">
	$(function() {
		LoadState();
		LoadState_Billing();
		
		$("#Pais").change(function(){
			$("#country").val($("#Pais").val());
			$("#province").val("");
			LoadState();
		});
		
		// Update State to textbox
		$("#State").change(function(){
			$("#province").val($("#State").val());
		});
		
		// Billing
		$("#Pais_billing").change(function(){
			LoadState_Billing();
		});
		
		// Update State to textbox
		$("#State_billing").change(function(){
			$("#province_billing").val($("#State_billing").val());
		});
		
		// check "same as above" checkbox
		$('#addAdress').bind('change', function () {
			if ($(this).is(':checked')) {
				var address1 = $('#Address1').val();
				var address2 = $('#Address2').val();
				var city = $('#City').val();
				var postal = $('#Zip').val();
				
				$("#Direccion1_billing").val(address1);
				$("#Direccion2_billing").val(address2);
				$("#Ciudad_billing").val(city);
				$("#Postal_billing").val(postal);
				
				if ($("#Pais").val() == 3 || $("#Pais").val() == 4 || $("#Pais").val() == 7 || $("#Pais").val() == 8 || $("#Pais").val() == 9 || $("#Pais").val() ==11 || $("#Pais").val() == 14 ) {
					$("#State_billing").attr("disabled", true);
					$("#Pais_billing").val($("#Pais").val());
					$("#country_billing").val($("#country").val());
					$("#province_billing").val($("#province").val());
					$("#td_province_billing").removeAttr("style");
				} else {
					$("#Pais_billing").val($("#Pais").val());
					LoadState_Billing();
					$("#State_billing").val($("#State").val());
					$("#country_billing").val($("#country").val());
					$("#province_billing").val($("#province").val());
				}
			} else {
				$("#State_billing").attr("disabled", false);
				$("#Direccion1_billing").val('');
				$("#Direccion2_billing").val('');
				$("#Ciudad_billing").val('');
				$("#Postal_billing").val('');
				$("#State_billing").val('select');
				$("#Pais_billing").val('USA');
				$("#country_billing").val('');
				$("#province_billing").val('');
				$("#td_pais_billing").css("display","none");
				$("#td_province_billing").css("display","none");
			}
		});
	
	});
	
	function LoadState(){
		$.ajax({
			type:"POST",
			url: "updateDropdownList_search.asp",
			dataType: "html",
			data: {
				CountryID:$("#Pais").val(),
				StadoName: $("#province").val()
				},
			async: false,
			success: function(data){
				if (data != "")
				{
					$("#State").html(data);
					$("#State").attr("disabled", false);
					$("#td_pais").css("display","none");
					$("#td_province").css("display","none");
					$("#country").val($("#Pais").val());
				}	
				else {
					$("#State").attr("disabled", true);
					$("#country").val($("#Pais").val());
					$("#province").val('');
					$("#td_province").removeAttr("style");
				}
			}
			});
		return false;
	}
	
	function LoadState_Billing(){
		$.ajax({
			type:"POST",
			url: "updateDropdownList_search.asp",
			dataType: "html",
			data: {CountryID:$("#Pais_billing").val(), StadoName: $("#province").val()},
			async: false,
			success: function(data){
				if (data != ""){
					$("#State_billing").html(data);
					$("#State_billing").attr("disabled", false);
					$("#td_pais_billing").css("display","none");
					$("#td_province_billing").css("display","none");
					$("#country_billing").val($("#Pais_billing").val());
				}	
				else {
					$("#State_billing").attr("disabled", true);
					$("#country_billing").val($("#Pais_billing").val());
					$("#province_billing").val('');
					$("#td_province_billing").removeAttr("style");
				}
			}
			});
		return false;
	}
	
  <!-- END DATE PICKER SCRIPT -->
</script>


<!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> -->
<script type="text/javascript">
$(function() {
    $('#list_table tr:nth-child(2n+1)').addClass('alternate');
});
</script>
<script language="javascript" type="text/javascript">
function checkValidation()
{
	if(document.getElementById('arrival1').value =="")
	{
		alert("Enter start date");
		document.getElementById('arrival1').focus();
		return false;
	}
	return true;
}
</script>

<title>Sales Buscar Huesped :: CostaBaja</title>
</head>
<%
if(Session("SalesAccessLevel") <> 1 and Session("SalesAccessLevel") <> 4 ) then
	Response.Redirect("default.asp?msg=invalid")
end if
if(Session("SalesId") <> "") then
	SaleID = Session("SalesId")
else 
	SaleID = 0
end if
SaleLever = Session("SalesAccessLevel")
									name = Cstr(Server.HTMLEncode(request("name"))) 
									mname =  Cstr(Server.HTMLEncode(request("mname")))
									sname =  Cstr(Server.HTMLEncode(request("sname")))
									city =  Cstr(Server.HTMLEncode(request("city")))
									Pais =  Cstr(Server.HTMLEncode(request("Pais")))
									Stado =  Cstr(Server.HTMLEncode(request("Stado")))
									email =  Cstr(Server.HTMLEncode(request("email")))
									property =  Cstr(Server.HTMLEncode(request("property")))
									kindOfInvestment =  Cstr(Server.HTMLEncode(request("kindOfInvestment")))
									Source = Cstr(Server.HTMLEncode(request("Source")))
									fecha =  Cstr(Server.HTMLEncode(request("fecha")))
									visitfecha =  Cstr(Server.HTMLEncode(request("visitfecha")))
									activity =  Cstr(Server.HTMLEncode(request("activity")))


'name = Cstr(request("name"))
'mname =  Cstr(request("mname"))
'sname =  Cstr(request("sname"))
'fecha =  Cstr(request("fecha"))
'visitfecha =  Cstr(request("visitfecha"))
'activity =  Cstr(request("activity"))
%>
<body>

<div id="main_wrapper">
    	<div class="main_wrapper_margin">
        	
            <div class="admin_top_menu">
            <%
				if(Session("SalesAccessLevel") = 4 ) then
			%>
            <!--#INCLUDE FILE="sales_menu_manage.asp"--> 
			<%
				else
			%>
			<!--#INCLUDE FILE="sales_menu.asp"--> 
			<%
				end if
			%>
           	</div>
             
			<h1>Buscar Huesped</h1>         
           
           <div class="clear"></div>
          
         <form method="get" action="sales-prospect-search.asp">
           <fieldset>
           	<legend>Informacion Personal</legend>
            <table cellpadding="0" width="100%">
            	
                <tr> <!-- ROW -->
                	<td width="33%">
            		<label>Nombre / First Name: </label><br />
					<input type="text" name="name" id="name" value="<%=name%>"/>
  					</td>
                    <td width="33%">
                    <label>Segundo Nombre / Middle Name: </label><br />
                    <input type="text" name="mname" id="mname" value="<%=mname%>"/>
            		</td>
                    <td width="33%">
                    <label>Apellido / Last Name: </label><br />
					<input type="text" name="sname" id="sname" value="<%=sname%>"/>
                    </td>
                </tr><!-- END ROW -->

				
                <tr> <!-- ROW -->
				
				<%
			sqlstring_Country = "SELECT  * FROM Country "
		set objConnect_Country = server.createObject("ADODB.Connection")   
		
		objConnect_Country.Open conStr

		set TblTemp_Country = server.createobject("Adodb.Recordset")
		TblTemp_Country.Open sqlstring_Country, objConnect_Country

		%>
                	<td width="33%">
            		<label>Ciudad / City: </label><br />
					<input type="text" name="city" id="city" value="<%=city%>"/>
  					</td>
                    <td>
				<label>Pais / Country: </label><br />
					<select id="Pais">
					<option value="">Seleccionar/Select One</option>
					<%
						Do Until TblTemp_Country.EOF
						cid = TblTemp_Country("CountryID")
						cName = TblTemp_Country("CountryName")
				   %>
						<option value="<%=cid%>"<% if(Pais = cStr(cid)) then%> selected="selected" <% end if%>><%=cName%></option>
					<%
						TblTemp_Country.MoveNext
						Loop
					%>
            	</td>
                    <td>
            	<label>Estado / Provincia: </label><br />
				<select id="State">
                  <option value='select' selected="selected">Seleccione Estado</option>
                  
                </select>
            		</td>
				</tr>
					<tr>
					<td id="td_pais" style="display:none">
					<label>Pais / Country: </label><br />
					 <input type="text" name="Pais" id="country" value="<%=Pais%>"/>
					</td>
					<td id="td_province" style="display:none">
					<label>Estado / Provincia: </label><br />
					 <input type="text" name="Stado" id="province" value="<%=Stado%>"/>
					</td>
					<td width="33%">
                    <label>E-mail: </label><br />
					<input type="text" name="email" id="email" value="<%=email%>"/>
            		</td>
                 </tr><!-- END ROW -->
                <tr><!-- ROW -->
					<td>
                  		<label>Propiedad / Property: </label><br />
            			<select name="property" id="property">
            			<option value="">Seleccionar/Select One</option>
            			<option value="VM"<% if(property = "VM") then%> selected="selected" <% end if%>>VistaMar</option>
                		<option value="LC"<% if(property = "LC") then%> selected="selected" <% end if%>>Las Colinas</option>
                		<option value="Las Colinas"<% if(property = "Las Colinas") then%> selected="selected" <% end if%>>Lomas</option>
                		<option value="Residence Club"<% if(property = "Residence Club") then%> selected="selected" <% end if%>>Residence Club</option>
            			</select>
            		</td>
					<td>
                      <label>Investment Kind: </label><br />
						<select id="kindOfInvestment" name="kindOfInvestment">
			    		<option value="">Seleccionar/Select One</option>
						<option value="Unknown"<% if(kindOfInvestment = "Unknown") then%> selected="selected" <% end if%>>Unknown</option>
            			<option value="lots"<% if(kindOfInvestment = "lots") then%> selected="selected" <% end if%>>Lots</option>
                		<option value="townHome"<% if(kindOfInvestment = "townHome") then%> selected="selected" <% end if%>>Town Homes</option>
                		<option value="condos"<% if(kindOfInvestment = "condos") then%> selected="selected" <% end if%>>Condos</option>
                		<option value="fractional"<% if(kindOfInvestment = "fractional") then%> selected="selected" <% end if%>>Fractional</option>
                    </td>
					<td>
						<label>Fuente / Source: </label><br />
            			<select name="Source" id="Source" >
			    		<option value="">Seleccionar/Select One</option>
            			<option value="Golf Course"<% if(Source = "Golf Course") then%> selected="selected" <% end if%>>Golf Course</option>
                		<option value="Hotel"<% if(Source = "Hotel") then%> selected="selected" <% end if%>>Hotel</option>
                        <option value="Beach Club"<% if(Source = "Beach Club") then%> selected="selected" <% end if%>>Beach Club</option>
                		<option value="Restaurant"<% if(Source = "Restaurant") then%> selected="selected" <% end if%>>Restaurant</option>
                        <option value="La Paz"<% if(Source = "La Paz") then%> selected="selected" <% end if%>>La Paz</option>
                		<option value="Colgey"<% if(Source = "Colgey") then%> selected="selected" <% end if%>>Colgey</option>
                		<option value="Marina"<% if(Source = "Marina") then%> selected="selected" <% end if%>>Marina</option>
                		<option value="Self Gen"<% if(Source = "Self Gen") then%> selected="selected" <% end if%>>Self Gen</option>
                		<option value="Walk In"<% if(Source = "Walk In") then%> selected="selected" <% end if%>>Walk In</option>
                		<option value="Phone Call"<% if(Source = "Phone Call") then%> selected="selected" <% end if%>>Phone Call</option>
                		<option value="Discover CostaBaja"<% if(Source = "Discover CostaBaja") then%> selected="selected" <% end if%>>Discover CostaBaja</option>
                		<option value="Cabo"<% if(Source = "Cabo") then%> selected="selected" <% end if%>>Cabo</option>
                		<option value="Other"<% if(Source = "Other") then%> selected="selected" <% end if%>>Other</option>
                        </select>
            		</td>
				</tr><!-- END ROW -->
				
                <tr> <!-- ROW -->
                    
                    <td>					
						<label>Actividad: </label><br />
            			<select id="activity" name="activity" >
						<option value="">-- Seleccionar --</option>
						<option value="Call" <% if(activity = "Call") then%> selected="selected" <% end if%>>Call</option>  
						<option value="Visit" <% if(activity = "Visit") then%> selected="selected" <% end if%>>Visit</option>     
               </select>
            		</td>
					<td>           
					<label>Fecha</label><br />
                    <input type="text" id="fecha" name="fecha" value="<%=fecha%>"/>   
            		</td>
					<td>           
					<label>Visita fecha</label><br />
                    <input type="text" id="visitfecha" name="visitfecha" value="<%=visitfecha%>"/>   
            		</td>
                 </tr><!-- END ROW -->
                 
                 <tr><!-- ROW -->
                 <td colspan="3" align="center">
                 
                 <input type="submit"  value="Buscar" />
                 
                 </td>
                 </tr><!-- END ROW -->
           
            </table>
            
           </fieldset>
           
           </form>

	<h3>Resultados</h3>
    
    <table id="list_table" width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr class="titles">
    <td>Actividad/Activity</td>
    <td>Prospect</td>
    <td>Fecha/Date</td>
	<td>Visita fecha/Visit Date</td>
     <td>&nbsp;</td>
  </tr>
  <%
														
		set objConnect = server.createObject("ADODB.Connection")       
		objConnect.open conStr
	
		Set oCmd = Server.CreateObject("ADODB.Command")
	  
		oCmd.ActiveConnection = objConnect
		oCmd.CommandText = "sp_search_prospect" 
		oCmd.CommandType = 4
		
		Set name = oCmd.CreateParameter("@name", 200,1,50,name)
		oCmd.Parameters.Append name
		
		Set midname = oCmd.CreateParameter("@midname", 200,1,50,mname)
		oCmd.Parameters.Append midname														
		
		Set surname = oCmd.CreateParameter("@surname", 200,1,50, sname)
		oCmd.Parameters.Append surname
		
		
		Set scity = oCmd.CreateParameter("@city", 200,1,50, city)
		oCmd.Parameters.Append scity
		
		
		Set sCountry = oCmd.CreateParameter("@country", 200,1,50, Pais)
		oCmd.Parameters.Append sCountry
		
		
		Set sprovince = oCmd.CreateParameter("@province", 200,1,50, Stado)
		oCmd.Parameters.Append sprovince
				
		Set semail = oCmd.CreateParameter("@email", 200,1,50, email)
		oCmd.Parameters.Append semail

		Set sproperty = oCmd.CreateParameter("@property", 200,1,50, property)
		oCmd.Parameters.Append sproperty
		
		Set skindOfInvestment = oCmd.CreateParameter("@kindofinvestment", 200,1,50, kindOfInvestment)
		oCmd.Parameters.Append skindOfInvestment		
		
		Set sSource = oCmd.CreateParameter("@source", 200,1,50, Source)
		oCmd.Parameters.Append sSource		
		
		Set fecha = oCmd.CreateParameter("@fecha", 200,1,50, fecha)
		oCmd.Parameters.Append fecha
		
		Set visitfecha = oCmd.CreateParameter("@visitfecha", 200,1,50, visitfecha)
		oCmd.Parameters.Append visitfecha
		
		Set activity = oCmd.CreateParameter("@activity", 200,1,50, activity)
		oCmd.Parameters.Append activity		
		
		Set salesid = oCmd.CreateParameter("@saleid", 200,1,50, SaleID)
		oCmd.Parameters.Append salesid
		
		Set saleslever = oCmd.CreateParameter("@salelever", 200,1,50, SaleLever)
		oCmd.Parameters.Append saleslever
		set rss =Server.CreateObject("ADODB.RecordSet")
		set rss = oCmd.execute
		
		if not rss.eof then	
															
			while not rss.eof
		%>
  <tr>
    <td>
	<%
		if(rss("Activity") = "Call") then
	%>
	<a href="sales-call-update-reschedule.asp?shID=<%=rss("ScheduceCallID")%>">Call</a>
	<%
	else
	%>
		<%=rss("Activity")%>
	<%
	end if
	%>
	</td>
    <td><%=rss("Name") & " " & rss("Middle") & " " & rss("Surname")%></td>
    <td><%=rss("Fercha")%></td>
    <td><%=rss("VisitDate")%></td>
	 <td><a href="sales-prospect-profile-page.asp?pID=<%=rss("GuestID")%>">Ver / View</a></td>
  </tr>
  <%
			
		rss.movenext
		wend
	else 
		%>
		<tr>
			<td colspan="10" class="list" align="center">No Prospect found!</td>
		</tr>
		<%
		end if
		objConnect.close()
		set objConnect = Nothing
	%>
</table>
    
    
           
           
    	</div><!-- END .main_wrapper_margin -->
	</div><!-- END #main_wrapper -->
         <!-- FOOTER -->
         
         <!--#INCLUDE file="sales_footer.asp"-->
         
         <!-- END FOOTER -->   
</body>
</html>
